Skip to content

fix: expand actively_monitored_wells to include wells from all groups(BDMS-974/1178) - #866

Open
likithabommasani21 wants to merge 6 commits into
stagingfrom
BDMS-974-a-4-fix-brittle-sql-filter-in-actively-monitored-wells
Open

fix: expand actively_monitored_wells to include wells from all groups(BDMS-974/1178)#866
likithabommasani21 wants to merge 6 commits into
stagingfrom
BDMS-974-a-4-fix-brittle-sql-filter-in-actively-monitored-wells

Conversation

@likithabommasani21

@likithabommasani21 likithabommasani21 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

BDMS-974/1178: Expand actively_monitored_wells to include wells from all groups

Why

  • actively_monitored_wells filtered wells with WHERE lower(trim(g.name)) = 'water level network' — a string match on a group's display name, restricting the layer to one group even though its name implies all actively monitored wells.
  • If that group were ever renamed, the filter would stop matching and the layer would silently return zero rows with no error (Section 4.3, R3).
  • A separate proposal to rename this layer to water_level_network_wells was withdrawn — the name was fine, the filter was just too narrow.

How

  • New Alembic migration (986e0eb85ab3) drops and recreates both ogc_actively_monitored_wells and its internal mirror ogc_internal_actively_monitored_wells, removing the group-name predicate. The status_value = 'Currently monitored' filter is untouched — that's the real definition of "actively monitored."

  • Verified against production data first: confirmed via a real query that no currently-monitored well has zero group memberships, so the existing inner-join structure is safe as-is (no need to switch to a LEFT JOIN).

  • Wells belonging to multiple groups are aggregated into one row (group_ids/group_names/group_types as parallel arrays) rather than one row per group, so id stays unique for pygeoapi's id_field: id lookups — verified live that duplicate rows silently broke /items/{id}.

  • Deduplicates group_thing_association rows first (no unique constraint exists on that table) and orders all three arrays by group_id, so they stay correctly aligned with each other rather than each being sorted independently.

  • Added a test (test_ogc_actively_monitored_wells_includes_wells_from_other_groups) proving a well in a group other than Water Level Network now shows up.

  • Rewrote the A4/A6 scenarios in ogc-cleanup-sprint1.feature, dropping the old rename/deprecation-header scenarios and the stale hardcoded "322" feature-count assertion (never matched real data in any environment we checked).

Notes

  • Found and separately flagged (not fixed here): a duplicate group row in prod, "water Level Network" (lowercase w) vs "Water Level Network", holding one stray well (WL-0428). Worth a data-cleanup follow-up.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Coverage

79.19% total — gate is 75%.

No measured coverage for the Python files changed here.

@likithabommasani21
likithabommasani21 force-pushed the BDMS-974-a-4-fix-brittle-sql-filter-in-actively-monitored-wells branch from 4d15dd1 to 1112edd Compare August 20, 2026 18:52
@jirhiker
jirhiker requested a lite review from Copilot August 22, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands actively monitored well OGC views to include wells from all groups while retaining the current monitoring filter.

Changes:

  • Recreates public and internal views without the group-name restriction.
  • Adds coverage for wells in other groups.
  • Updates related OGC cleanup scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Summary
tests/test_ogc.py Adds regression coverage for wells in non-default groups.
tests/features/ogc-cleanup-sprint1.feature Updates A4/A6 OGC scenarios and removes stale assertions.
alembic/versions/986e0eb85ab3_expand_actively_monitored_wells_to_all_.py Requires a public group-release filter (critical, 3 votes), coverage for the internal mirror (moderate, 2 votes), and unique feature IDs for per-group rows (critical, 1 vote).
Suppressed comments (1)

tests/test_ogc.py:597

  • This migration changes both the public and internal views, but the new regression test only queries ogc_actively_monitored_wells. A regression in _create_internal_actively_monitored_wells_view() would still pass, leaving /ogcapi-internal with the old group-name restriction; run the same assertion against both relations (or exercise the internal endpoint) so both changed definitions are covered.
        row = session.execute(
            text(
                "SELECT group_id, group_name, group_type "
                "FROM ogc_actively_monitored_wells WHERE id = :thing_id"
            ),

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread alembic/versions/986e0eb85ab3_expand_actively_monitored_wells_to_all_.py Outdated
Comment thread alembic/versions/986e0eb85ab3_expand_actively_monitored_wells_to_all_.py Outdated
@likithabommasani21
likithabommasani21 force-pushed the BDMS-974-a-4-fix-brittle-sql-filter-in-actively-monitored-wells branch from 9cc8ae7 to 1bdabcc Compare August 24, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants